Left Termination of the query pattern balance_in_2(a, g) w.r.t. the given Prolog program could not be shown:



Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof

Clauses:

balance(T, TB) :- balance(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])).
balance(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)).
balance(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) :- ','(balance(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)), balance(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))).

Queries:

balance(a,g).

We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof
  ↳ PrologToPiTRSProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(T, TB) → U11(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN(T, TB) → BALANCE_IN(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U31(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out
BALANCE_IN(x1, x2)  =  BALANCE_IN(x2)
U31(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U31(x18)
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)
U11(x1, x2, x3)  =  U11(x3)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(T, TB) → U11(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN(T, TB) → BALANCE_IN(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U31(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out
BALANCE_IN(x1, x2)  =  BALANCE_IN(x2)
U31(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U31(x18)
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)
U11(x1, x2, x3)  =  U11(x3)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 1 SCC with 3 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
PiDP
              ↳ UsableRulesProof
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
PiDP
                  ↳ PiDPToQDPProof
  ↳ PrologToPiTRSProof

Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))

The argument filtering Pi contains the following mapping:
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
QDP
                      ↳ Narrowing
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

BALANCE_INBALANCE_IN
BALANCE_INU21(balance_in)
U21(balance_out) → BALANCE_IN

The TRS R consists of the following rules:

balance_inU2(balance_in)
balance_inbalance_out
U2(balance_out) → U3(balance_in)
U3(balance_out) → balance_out

The set Q consists of the following terms:

balance_in
U2(x0)
U3(x0)

We have to consider all (P,Q,R)-chains.
By narrowing [15] the rule BALANCE_INU21(balance_in) at position [0] we obtained the following new rules:

BALANCE_INU21(balance_out)
BALANCE_INU21(U2(balance_in))



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
                    ↳ QDP
                      ↳ Narrowing
QDP
                          ↳ NonTerminationProof
  ↳ PrologToPiTRSProof

Q DP problem:
The TRS P consists of the following rules:

BALANCE_INBALANCE_IN
BALANCE_INU21(balance_out)
BALANCE_INU21(U2(balance_in))
U21(balance_out) → BALANCE_IN

The TRS R consists of the following rules:

balance_inU2(balance_in)
balance_inbalance_out
U2(balance_out) → U3(balance_in)
U3(balance_out) → balance_out

The set Q consists of the following terms:

balance_in
U2(x0)
U3(x0)

We have to consider all (P,Q,R)-chains.
We used the non-termination processor [17] to show that the DP problem is infinite.
Found a loop by semiunifying a rule from P directly.

The TRS P consists of the following rules:

BALANCE_INBALANCE_IN
BALANCE_INU21(balance_out)
BALANCE_INU21(U2(balance_in))
U21(balance_out) → BALANCE_IN

The TRS R consists of the following rules:

balance_inU2(balance_in)
balance_inbalance_out
U2(balance_out) → U3(balance_in)
U3(balance_out) → balance_out


s = BALANCE_IN evaluates to t =BALANCE_IN

Thus s starts an infinite chain as s semiunifies with t with the following substitutions:




Rewriting sequence

The DP semiunifies directly so there is only one rewrite step from BALANCE_IN to BALANCE_IN.




We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x2, x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out(x2)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x2, x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out(x2)


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(T, TB) → U11(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN(T, TB) → BALANCE_IN(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U31(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x2, x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out(x2)
BALANCE_IN(x1, x2)  =  BALANCE_IN(x2)
U31(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U31(x18)
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)
U11(x1, x2, x3)  =  U11(x2, x3)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(T, TB) → U11(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
BALANCE_IN(T, TB) → BALANCE_IN(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U31(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x2, x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out(x2)
BALANCE_IN(x1, x2)  =  BALANCE_IN(x2)
U31(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U31(x18)
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)
U11(x1, x2, x3)  =  U11(x2, x3)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 1 SCC with 3 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
PiDP
              ↳ UsableRulesProof

Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance_in(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, [])))
balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))
U1(T, TB, balance_out(T, -(I, []), -(.(','(TB, -(I, [])), X), X), -(Rest, []), -(Rest, []))) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x2)
U1(x1, x2, x3)  =  U1(x2, x3)
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
balance_out(x1, x2)  =  balance_out(x2)
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
PiDP
                  ↳ PiDPToQDPProof

Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → BALANCE_IN(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))
BALANCE_IN(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
U21(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → BALANCE_IN(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))

The TRS R consists of the following rules:

balance_in(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT)) → U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1)))
balance_in(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) → balance_out(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T))
U2(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(L, -(IH, .(V, IT1)), -(H, T), -(HR1, TR1), -(NH, NT1))) → U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_in(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT)))
U3(L, V, R, IH, IT, LB, VB, RB, A, D, H, X, T, HR, TR, NH, NT, balance_out(R, -(IT1, IT), -(HR1, TR1), -(HR, TR), -(NT1, NT))) → balance_out(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(NH, NT))

The argument filtering Pi contains the following mapping:
balance_in(x1, x2, x3, x4, x5)  =  balance_in
-(x1, x2)  =  -(x1, x2)
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U2(x18)
nil  =  nil
balance_out(x1, x2, x3, x4, x5)  =  balance_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U3(x18)
BALANCE_IN(x1, x2, x3, x4, x5)  =  BALANCE_IN
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18)  =  U21(x18)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
QDP
                      ↳ Narrowing

Q DP problem:
The TRS P consists of the following rules:

BALANCE_INBALANCE_IN
BALANCE_INU21(balance_in)
U21(balance_out) → BALANCE_IN

The TRS R consists of the following rules:

balance_inU2(balance_in)
balance_inbalance_out
U2(balance_out) → U3(balance_in)
U3(balance_out) → balance_out

The set Q consists of the following terms:

balance_in
U2(x0)
U3(x0)

We have to consider all (P,Q,R)-chains.
By narrowing [15] the rule BALANCE_INU21(balance_in) at position [0] we obtained the following new rules:

BALANCE_INU21(balance_out)
BALANCE_INU21(U2(balance_in))



↳ Prolog
  ↳ PrologToPiTRSProof
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
                    ↳ QDP
                      ↳ Narrowing
QDP
                          ↳ NonTerminationProof

Q DP problem:
The TRS P consists of the following rules:

BALANCE_INBALANCE_IN
BALANCE_INU21(balance_out)
BALANCE_INU21(U2(balance_in))
U21(balance_out) → BALANCE_IN

The TRS R consists of the following rules:

balance_inU2(balance_in)
balance_inbalance_out
U2(balance_out) → U3(balance_in)
U3(balance_out) → balance_out

The set Q consists of the following terms:

balance_in
U2(x0)
U3(x0)

We have to consider all (P,Q,R)-chains.
We used the non-termination processor [17] to show that the DP problem is infinite.
Found a loop by semiunifying a rule from P directly.

The TRS P consists of the following rules:

BALANCE_INBALANCE_IN
BALANCE_INU21(balance_out)
BALANCE_INU21(U2(balance_in))
U21(balance_out) → BALANCE_IN

The TRS R consists of the following rules:

balance_inU2(balance_in)
balance_inbalance_out
U2(balance_out) → U3(balance_in)
U3(balance_out) → balance_out


s = BALANCE_IN evaluates to t =BALANCE_IN

Thus s starts an infinite chain as s semiunifies with t with the following substitutions:




Rewriting sequence

The DP semiunifies directly so there is only one rewrite step from BALANCE_IN to BALANCE_IN.